<template>
	<view>
		<image style="width: 400rpx;height: 400rpx; position: absolute; left: 20%; top:20%;"
		    src="https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/wujilu.png" :class="answerList.length === 0 ? 'show' : 'hidde' "></image>
		
		<uni-card v-for="(record,index) in answerList" :key="index" :title="record.skillTitle+getBatch(record)" 
			:extra="record.createTime" @click="openAnswer(record.examId)">
			<uni-row>
				<uni-col :span="4">
					<view style="text-align: center;">
						一共
					</view>
				</uni-col>
				<uni-col :span="4" :offset="1">
					<view style="text-align: center;">
						答对
					</view>
				</uni-col>
				<uni-col :span="4" :offset="1">
					<view style="text-align: center;">
						答错
					</view>
				</uni-col>
				<uni-col :span="4" :offset="1">
					<view style="text-align: center;">
						未答
					</view>
				</uni-col>
				<uni-col :span="4" :offset="1">
					<view style="text-align: center;">
						及格
					</view>
				</uni-col>
			</uni-row>
			<uni-row>
				<uni-col :span="4">
					<view style="color: #0096dc;text-align: center;">
						{{record.totalQuestions}}
					</view>
				</uni-col>
				<uni-col :span="4" :offset="1">
					<view style="color: #00d89f;text-align: center;">
						{{record.correctQuestions}}
					</view>
				</uni-col>
				<uni-col :span="4" :offset="1">
					<view style="color: red;text-align: center;">
						{{record.errorQuestions}}
					</view>
				</uni-col>
				<uni-col :span="4" :offset="1">
					<view style="color: red;text-align: center;">
						{{record.notQuestions}}
					</view>
				</uni-col>
				<uni-col :span="4" :offset="1">
					<view v-if="record.isPassed" style="color: #00d89f;text-align: center;">
						是
					</view>
					<view v-else  style="color: red;text-align: center;">
						否
					</view>
				</uni-col>
			</uni-row>
		</uni-card>
	</view>
</template>

<script>
	import knowledge from '@/api/modules/knowledge'
	
	export default {
		data() {
			return {
				answerList : []
			}
		},
		created() {
			this.initData();
		},
		methods: {
			initData() {
				knowledge.getUserAnswerRecordList(uni.getStorageSync("loginId")).then(res=> {
					this.answerList = res.data;
				})
			},
			openAnswer(id) {
				uni.navigateTo({
					url: `/pages_duty/common/knowledge/skills/questions?examId=${id}`
				})
			},
			getBatch(record) {
				if(record.studyBatch !== 0) {
					return '(第'+record.studyBatch+'批次)'
				}else {
					return '' 
				}
			}
		}
	}
</script>

<style>
	.show {
		display: block;
	}
	.hidde {
		display: none;
	}
</style>
